package com.chezhujie.www.service;

import com.chezhujie.www.domain.*;
import com.chezhujie.www.persistence.Czjtop3Mapper;
import com.sys.core.page.Pagination;
import com.sys.core.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("Czjtop3Service")
public class Czjtop3Service {
	@Autowired
	private Czjtop3Mapper czjtop3Mapper;

	
	
	public Czjfestivalact getCzjfestivalact(Map<String, Object> param) {
		
		return czjtop3Mapper.getCzjfestivalact(param);
	}	
	
	/**
	 * 查询某个czj_top3  季节
	 * @param param
	 * @return
	 */
	public Czjtop3 getCzjtop3(Map<String,Object> param) {
		return czjtop3Mapper.getCzjtop3(param);
	}
	

	
	/**
	 * 查询某个czj_top3  季节
	 * @param param
	 * @return
	 */
	public List<String> getCzjtop3ALL() {
		return czjtop3Mapper.getCzjtop3ALL();
	}	
   
	/**
	 * 查询某个czj_top3  季节queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjtop3 queryImgOrder(Map<String,Object> param) {
		return czjtop3Mapper.queryImgOrder(param);
	}	
	
	/**
	 * 查询czj_top3  季节列表
	 * @return
	 */
	public Map<String,Object> getCzjtop3List(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjtop3Mapper.getTotalRows(param));
		returnMap.put("list", czjtop3Mapper.getCzjtop3List(param));
		return returnMap;
	}
   
	
	/**
	 * 查询czj_top3  季节列表
	 * @return
	 */
	public  List<Czjtop3> getCzjtop3ListALL(Map<String,Object> param) {
		List<Czjtop3> list=	czjtop3Mapper.getCzjtop3ListALL(param);
		return list;
		
	}	
	
	
	/**
	 * 查询所有活动
	 * @return
	 */
	public  List<Czjfestivalact> getCzjactListALL(Map<String,Object> param) {
		List<Czjfestivalact> list=	czjtop3Mapper.getCzjactListALL(param);
		return list;
		
	}	
	
	/**
	 * 查询所有商家
	 * @return
	 */
	public  List<Czjbusiness> getCzjbusinessListALL(Map<String,Object> param) {
		List<Czjbusiness> list=	czjtop3Mapper.getCzjbusinessListALL(param);
		return list;
		
	}	
	
	/**
	 * 查询所有商家对应的商品
	 * @return
	 */
	public  List<Czjcommodity> getCzjcommodityList(Map<String,Object> param) {
		List<Czjcommodity> list=	czjtop3Mapper.getCzjcommodityList(param);
		return list;
		
	}		
	
	
	/**
	 * 查询所有季节
	 * @return
	 */
	public  List<Czjseason> getCzjseasonListALL(Map<String,Object> param) {
		List<Czjseason> list=	czjtop3Mapper.getCzjseasonListALL(param);
		return list;
		
	}		
	
	
	
	
	
	/**
	 * 查询czj_top3  季节列表
	 * @return
	 */
	public Pagination getCzjtop3List(Map<String,Object> param, int pageSize, Integer pageNo, String order, String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjtop3Mapper.getTotalRows(param);
		List<Czjtop3> list=	czjtop3Mapper.getCzjtop3List(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_top3  季节
	 * @param czjtop3
	 * @param param
	 */
	@Transactional
	public void insertCzjtop3(Czjtop3 czjtop3) {	
		czjtop3.setTop3Id(UUIDUtils.getUUID());
		czjtop3Mapper.insertCzjtop3(czjtop3);
	}
   
	/**
	 * 编辑czj_top3  季节
	 * @param czjtop3
	 * @param param
	 */
	@Transactional
	public void updateCzjtop3(Czjtop3 czjtop3) {
		czjtop3Mapper.updateCzjtop3(czjtop3);
	}
   
	/**
	 * 删除czj_top3  季节
	 * @param param
	 */    
	@Transactional
	public void deleteCzjtop3(List<String> top3IdList) {
		for(String top3Id: top3IdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("top3Id", top3Id);
	 	   czjtop3Mapper.deleteCzjtop3(param);	  		
		}
	}


	public List<Czjtop3> getListBy(Map<String, Object> param) {
		return czjtop3Mapper.getCzjtop3List(param);
	}
}